package com.blkan.calculator.fragments;

import android.annotation.SuppressLint;
import android.view.View;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.blkan.calculator.R;
import com.blkan.calculator.util.SqliteHelper;

import java.util.Objects;

public class HistoryFragment extends BasicFragment{

    private RecyclerView recyclerView;

    @Override
    public int getLayoutResId() {
        return R.layout.fragment_history;
    }

    @SuppressLint("NotifyDataSetChanged")
    @Override
    public void initView(View rootView) {
        recyclerView = rootView.findViewById(R.id.recyclerView_history);
        recyclerView.setAdapter(new HistoryItemAdapter(this));
        LinearLayoutManager layoutManager = new LinearLayoutManager(rootView.getContext());
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
        SqliteHelper helper = new SqliteHelper(getContext());
        helper.readAndStoreData();
        Objects.requireNonNull(recyclerView.getAdapter()).notifyDataSetChanged();
    }

}
